<%= render partial: 'subnav' %>

<h2>
  From
  <% if @message.author %>
    <%= styled_user_link @message.author %>
  <% else %>
    <%= @message.author_username %>
  <% end %>
  <%= @message.hat.to_html_label if @message.hat %>
  to
  <%= styled_user_link @message.recipient %>
  <%= how_long_ago_label(@message.created_at) %>
</h2>

<div class="comment_text">
  <%= raw @message.linkified_body %>
</div>

<div class="row">
  <%= form_with url: message_path(@message.short_id), method: :delete do |f| %>
    <%= f.submit "Delete Message" %>
  <% end %>

  <%= form_with url: message_keep_as_new_path(@message.short_id), method: :post do |f| %>
    <%= f.submit "Keep As New" %>
  <% end %>

  <% if @user.is_moderator? %>
    <%= form_with url: message_mod_note_path(@message.short_id), method: :post do |f| %>
      <%= f.submit "ModNote" %>
    <% end %>
  <% end %>
</div>

<% if @new_message %>
  <p>
    Compose Reply
    <% if @new_message %>
      To <%= @new_message.recipient_username %>
    <% end %>
  </p>

  <%= render partial: 'form', locals: { new_message: @new_message, replying: true } %>
<% else %>
  For help with this message, contact <%= link_to 'a moderator', moderators_path %>.
<% end %>
